{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "┌ Info: Loading FMNIST...\n",
      "└ @ Main /kuacc/users/dyuret/.julia/dev/Knet/data/fashion-mnist.jl:37\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SubString{String}[\"Bag\", \"Trouser\", \"Sandal\"]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAQhSURBVGje7dpPiBxFFMfxz+zM7E7WVclu3JiI2SgiiBH1oije9OLBm/gPDwqagCe9efAiKgh6ySEXFcWLIhIF/90EQU9KIoJ7iQbx38Y/iRqyq7N/x8OrpsfpGfESeyjS0Ex1VXW9+c13XtV71d0wcDTSZy+V21hLdbtwF7an9l/wIY713d/ChtHHhP/5yN9gY1RDP4s9eAIzWMTH2MR1uBLTeBfvpP7t1N5LZ60K8zc4lGFTMIBHcTtexhsjBtmb+s3heXzRp2arboX5G6wwbGM9lV8UfrS/r72j9K9G6ltwuhWP4CieSXX9/4daFOZvcORc+iq6OJCuO1hVnRuJeZdy7n1TcLtnHBTmb3Aow4OC2YGBToXv9f5loKJtP67CY3UrzN9ga7BiAdfgCB7Hs/7JrDdioP76qTTObSLe+bNOhfkbrDC8WMSfO3ERdmPJf8sZttK9L6V7fxd5yDmGZ/WoMLxQxDXzOIUn8bDgNyzONFD/HL7C97gJl+HHOhXmb7DCcLuIJWdwUuSAD+IVJad2KhdrYOGft2Af3hPx0KTwx1oV5m+wwvACwaTg8yUewCfCvyhzj/7jvtTvA5H3f4u/cD3erlNh/gYrDKeF73wt5tXPxXz4luDzguAzIfx1Hx7CDfgsDTgv8pAl8Z+oVWH+BisMvxF+1hPxzbzguYhL8bSIO2fxnfC1H9K5gDvwk4iJOni/boX5G6ww3J0+N8We9pzwzeM4I9bJo2L/e1Xsh+9N5yVYSX1Wk5rjdSvM32CF4Y0iJ1gWzFYEn5vFenhMrJdLgtUCLhe+uZz6d5OSmdSvVoX5G6ww3CnyuYZYB88T/riBq0X+PyHm28E9tkZqOz9dT+HnuhXmb7DCcFbMg02RP6wLJp1U3hBcm2ItbCr3aHrYlu5bE/Nxt26F+RusMOyK/G9SxDdz2KHMB1tKf+uk64lUV7Ar/Hh5HBTmb7DCcE3kA2dSufC9CeFnLeFfa4LZlmDeSPWbfeW5cVCYv8Gh+eG0YNAR/ljEKFL9hpLbal9bsS6uC1/cMw4K8zdYYfgp7hbrWvE8eEusie2+bzmVysW610t9i/cwhg5eh8L8DVZ+5kO4X7BoKmOZntL3irWvOItv3lbOtU2RZ9SuMH+DFYbH8YeYB0+K2HMDpwWbScGtYNZTxkFN5brZEM/za1eYv8Fh052nxL7otSK/Wxf5xLRyDaSMXzqC9aTgt5U+D4+DwvwNjnyf5rB4lgQn8JtYE6dTXUuwLebLnvDDrmB7AveOg8L8DbZGNWwTe9ptsWc2qYxzitx9RZl3FPFqQ+z1HEzjDL5/k/9POj5+eET4XRe/prpdgtOGYDqb6jaFTy6m/ofw+rgozN/gSIY7cKd4PtgUzxKvSN/wtOD3EV5L16fSOajm3DvCZ/34G93f8ynkaIcpAAAAAElFTkSuQmCC",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " ⋮                                                                               ⋱  ⋮                                                         \n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAJaSURBVGje7ZpNS1RhFMd/t5nRTCwUAwPLcBO2TjDa+gHauvYj9ClcBH0DwW/Qup0u2ghS0MKIKI3U8iUdmxmbGcfFOZf7eN2chTiHQxcu5+HhzvM//+fHvc/bZBivN0AHaAB1YBAYAMaAM+CVsZ1bVsHruuILZtYHe9fUUPwuvXHBquWh5xq3kHcvA1r64y7wCHgGrHt0GF/QxHBWY4Yw7GmsIt9WgBn+M+yToInhY40Z8t51gXOty+Ndrw7jC5oYTiDvXqYZpnc+Do57dRhf0MTwAdCkeA9HNP4DKlp+4tVhfEETQxB+5/qDY2Q8BGH4F+Hs0mF8QRPDqmbWRtaDy8Ao8BL4jnC0Zh6/S30y3AZeUMxfBoA/Wm4DQ8Bvrw7jC5oYfgQWkPEPYAf4peWeZr3p1WF8QRPDnM8djZ+Bb1rOx8Utrw7jC5oYrmqsaDxCxsE04y9eHcYXNDE8KD18BuyWMn7v1WF8QfPa4icwrOV94ETLNY0NYzvxu9Qvwx/AUy0flBrY8+wwvqCZ4VGSXTupr3GZqTuH8QXNDIeT7HZKDVj3u/viML6gmeEMxRq/pXEbuI/Mcdw6jC9oZrgLTJbqOnrfA6aBrx4dxhc0M6wg+977SV1N66rI/2tcOowvaGZYR5il380OwraFfW4av0v9MuwCtynW9iB7Mw+Rs6hDrw7jC5oZfgLmkHlMfr0D5inOMFw6jC9oZrgGLHKV4RLynXXrML6gmeEHjeme2oZG69lhXxzGFzQzzM+fppK6IY2nnh3GFzQzbAKvuXzW2wRWgLeeHcYXvAB00mP7iafgvQAAAABJRU5ErkJggg==",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " ⋮                                                                               ⋱  ⋮                                                         \n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAO+SURBVGje7dpbjF1jFAfw35k5NaOMa0vrfku8NBqmbUgJRYRKvAgqg4cKD4hbRFJEIpGIiIQgcemL8MKLuIQSRSiJqEZUEYkhEyadujX0NqfnTD2sbzs7E03qNJ1tvpyV7Ozsb1/WXt9/r/Vfa32brnSlK1VLbW9u7kEvmthVGj8Fl+PhdNyLVumeKZX8FdY7uamWtom0leUJrMBV+ACfJqu6GO4z6cgPa8Lv9sdBOARDWIYt2CR8cRgXYT80qrIwf4Ud+WEdO/EcFgrcTiydPxqjGEnHjWTZRBUW5q+wIwwL7htN+xbewwzMw0x8LPBdgYfQh+1VWJi/wr2KpXAW7sePuBK/4jich1twTUlJrQoL81fYcV5axnFUcF4d2zBXYNfE45iPMeGn+U/p9IilRLzcipUir9ks4uXBeBWn4gz8jqvxmODQ/Kd0+vhhkWtejHtxAvoxC3OEj34hPpLPcGlVFuavsGM/LGQu1mI2BoSvzcc72IBBnCTiaNcP94l0XOMX9d75eAm34xcRY49I5y7AzzgSj+LWKizMX2HHGBb5zFq8gXHha2OivoDrRc66E2dXZWH+Cv8zH/ZqY9jCkvTWTwp/a+BNLE/XjwhsB3BDFRbmr3CP/bDokbYmjc/Cy/hJ1PAzBDcW8rbonX6Od6uwMH+Fe4RhkY/sEr3RlTgMt6X9KoFbj6gtymsYqwVnrhF8mf+U/v8wLPer1+EHnCs4cH3ansGXAudNAuMh3CN4sqg5KrEwf4W7xbDgvAaOxSWin0b0P2+edP33Aqc+PIVj8BX+FHH266oszF9hfXeDEwLDQVyG1/BsGhsT/bX78CDuxFE4HU8L3IYEhr+JODuzKgvzV/ivGDbTfqHooT0v1gIJnD7ER4IbX0/Xrcdp+BaLcZ2IowMiX91elYX5K/wHw3LNtxjH4y0x/wsEhjXRP7sRd+FQwXXLxJp9IXNE/ton+HS8SgvzV1gvrwe1RP96ucBuNRZpA11g/I3IR9eJ9abif4y68OFmelZx/RZtHPOf0qnHsKjVC2kKrtuIu/EKzimdvwkPiHri2jRWzl0JzIZFTVLDgdrxOf8prSaWzsPJgrs2Csw+EbnmmrT14BFcgTvwYnpAP3ZMevu/BGY1sZ64WeBZiYX5K6wvFf8QrhL8NiLWBZcIPluKA0Te8j4uxHeltx3X5tIidtaFb24T/02dqV2X5D+l1fRLB0Vt0C/8Z6uoBfoFfg3BfRvSTUXfZrIUfHi4WMsYxh/iW3hB9Nvyn9IpV9iV6S9/A3aNyIgyRrE8AAAAAElFTkSuQmCC",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)         …  Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)         …  Gray{Float32}(0.00784314)  Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0352941)   Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.00392157)\n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0196078) \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)         …  Gray{Float32}(0.0)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0196078)   Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.572549)    Gray{Float32}(0.0)       \n",
       " ⋮                                                                               ⋱                                                      \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.521569)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.6)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.435294)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.47451)     Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)         …  Gray{Float32}(0.439216)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.00392157)     Gray{Float32}(0.439216)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.00392157)  Gray{Float32}(0.0117647)  Gray{Float32}(0.0117647)      Gray{Float32}(0.411765)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.396078)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.172549)   Gray{Float32}(0.309804)       Gray{Float32}(0.415686)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.290196)    Gray{Float32}(0.827451)   Gray{Float32}(0.545098)    …  Gray{Float32}(0.494118)    Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.2)        Gray{Float32}(0.301961)       Gray{Float32}(0.2)         Gray{Float32}(0.0)       \n",
       " Gray{Float32}(0.0)         Gray{Float32}(0.0)        Gray{Float32}(0.0)            Gray{Float32}(0.0)         Gray{Float32}(0.0)       "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Take a look at some random images and labels in data\n",
    "using Pkg; for p in (\"Knet\",\"Images\",\"ImageMagick\"); haskey(Pkg.installed(),p) || Pkg.add(p); end\n",
    "using Knet,Images,Random\n",
    "include(Knet.dir(\"data\",\"fashion-mnist.jl\"))\n",
    "xtrn,ytrn,xtst,ytst,lbls = fmnist()\n",
    "rp = randperm(10000)\n",
    "println(lbls[ytst[rp[1:3]]]); flush(stdout)\n",
    "for i=1:3; display(fmnistview(xtst,rp[i])); end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Main.FashionMNIST"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "include(\"fashion-mnist.jl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "This example learns to classify images of fashion products(trousers, shirts, bags...)  from the [Fashion-MNIST](https://github.com/zalandoresearch/fashion-mnist) dataset.   There are 60000 training and 10000 test examples. Each input x  consists of 784 pixels representing a 28x28 image. The pixel values are  normalized to [0,1]. Each output y is converted to a ten-dimensional  one-hot vector (a vector that has a single non-zero component) indicating  the correct class (0-9) for a given image. 10 is used instead of 0. Labels and descriptions are shown below.\n",
       "\n",
       "```\n",
       "Label   Description\n",
       "1       T-shirt/top\n",
       "2       Trouser\n",
       "3       Pullover\n",
       "4       Dress\n",
       "5       Coat\n",
       "6       Sandal\n",
       "7       Shirt\n",
       "8       Sneaker\n",
       "9       Bag\n",
       "10      Ankle boot\n",
       "```\n",
       "\n",
       "You can run the demo using `julia fashion-mnist.jl` on the command line or by first including `julia> include(\"fashion-mnist.jl\")` and typing `julia> FashionMNIST.main()`  at the Julia prompt.  Options can be used like `julia fashion-mnist.jl --epochs 3`  or `julia> FashionMNIST.main(\"--epochs 3\")`. Use `julia fashion-mnist.jl --help`  for a list of options.  The dataset will be automatically downloaded.   By default a softmax model will be trained for 10 epochs. You can also  train a multi-layer perceptron by specifying one or more –hidden sizes.  The accuracy for the training and test sets will be printed at every epoch  and optimized parameters will be returned.\n"
      ],
      "text/plain": [
       "  This example learns to classify images of fashion products(trousers, shirts, bags...) from the Fashion-MNIST\n",
       "  (https://github.com/zalandoresearch/fashion-mnist) dataset. There are 60000 training and 10000 test examples. Each input x consists of 784 pixels\n",
       "  representing a 28x28 image. The pixel values are normalized to [0,1]. Each output y is converted to a ten-dimensional one-hot vector (a vector that\n",
       "  has a single non-zero component) indicating the correct class (0-9) for a given image. 10 is used instead of 0. Labels and descriptions are shown\n",
       "  below.\n",
       "\n",
       "\u001b[36m  Label   Description\u001b[39m\n",
       "\u001b[36m  1       T-shirt/top\u001b[39m\n",
       "\u001b[36m  2       Trouser\u001b[39m\n",
       "\u001b[36m  3       Pullover\u001b[39m\n",
       "\u001b[36m  4       Dress\u001b[39m\n",
       "\u001b[36m  5       Coat\u001b[39m\n",
       "\u001b[36m  6       Sandal\u001b[39m\n",
       "\u001b[36m  7       Shirt\u001b[39m\n",
       "\u001b[36m  8       Sneaker\u001b[39m\n",
       "\u001b[36m  9       Bag\u001b[39m\n",
       "\u001b[36m  10      Ankle boot\u001b[39m\n",
       "\n",
       "  You can run the demo using \u001b[36mjulia fashion-mnist.jl\u001b[39m on the command line or by first including \u001b[36mjulia> include(\"fashion-mnist.jl\")\u001b[39m and typing \u001b[36mjulia>\n",
       "  FashionMNIST.main()\u001b[39m at the Julia prompt. Options can be used like \u001b[36mjulia fashion-mnist.jl --epochs 3\u001b[39m or \u001b[36mjulia> FashionMNIST.main(\"--epochs 3\")\u001b[39m. Use\n",
       "  \u001b[36mjulia fashion-mnist.jl --help\u001b[39m for a list of options. The dataset will be automatically downloaded. By default a softmax model will be trained for\n",
       "  10 epochs. You can also train a multi-layer perceptron by specifying one or more –hidden sizes. The accuracy for the training and test sets will be\n",
       "  printed at every epoch and optimized parameters will be returned."
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@doc FashionMNIST"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "usage: <PROGRAM> [--seed SEED] [--batchsize BATCHSIZE]\n",
      "                 [--epochs EPOCHS] [--hidden [HIDDEN...]] [--lr LR]\n",
      "                 [--winit WINIT] [--fast] [--atype ATYPE]\n",
      "                 [--gcheck GCHECK] [--dropout DROPOUT]\n",
      "\n",
      "fashion-mnist.jl (c) 2017 Adapted by Emre Unal based on Deniz Yuret’s\n",
      "MNIST example\n",
      "https://github.com/denizyuret/Knet.jl/tree/master/examples/mnist-mlp/mlp.jl.\n",
      "Multi-layer perceptron model on the Fashion-MNIST dataset from\n",
      "https://github.com/zalandoresearch/fashion-mnist.\n",
      "\n",
      "optional arguments:\n",
      "  --seed SEED           random number seed: use a nonnegative int for\n",
      "                        repeatable results (type: Int64, default: -1)\n",
      "  --batchsize BATCHSIZE\n",
      "                        minibatch size (type: Int64, default: 100)\n",
      "  --epochs EPOCHS       number of epochs for training (type: Int64,\n",
      "                        default: 10)\n",
      "  --hidden [HIDDEN...]  sizes of hidden layers, e.g. --hidden 128 64\n",
      "                        for a net with two hidden layers (type: Int64)\n",
      "  --lr LR               learning rate (type: Float64, default: 0.15)\n",
      "  --winit WINIT         w initialized with winit*randn() (type:\n",
      "                        Float64, default: 0.1)\n",
      "  --fast                skip loss printing for faster run\n",
      "  --atype ATYPE         array type: Array for cpu, KnetArray for gpu\n",
      "                        (default: \"KnetArray{Float32}\")\n",
      "  --gcheck GCHECK       check N random gradients per parameter (type:\n",
      "                        Int64, default: 0)\n",
      "  --dropout DROPOUT     Dropout probability. (type: Float64, default:\n",
      "                        0.5)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "FashionMNIST.main(\"--help\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fashion-mnist.jl (c) 2017 Adapted by Emre Unal based on Deniz Yuret’s MNIST example https://github.com/denizyuret/Knet.jl/tree/master/examples/mnist-mlp/mlp.jl.\n",
      "Multi-layer perceptron model on the Fashion-MNIST dataset from https://github.com/zalandoresearch/fashion-mnist.\n",
      "\n",
      "opts=(:batchsize, 100)(:fast, false)(:atype, \"KnetArray{Float32}\")(:epochs, 10)(:gcheck, 0)(:winit, 0.1)(:dropout, 0.5)(:lr, 0.15)(:hidden, Int64[])(:seed, -1)\n",
      "(:epoch, 0, :trn, 0.12296666666666667, :tst, 0.1225)\n",
      "(:epoch, 1, :trn, 0.8116, :tst, 0.8001)\n",
      "(:epoch, 2, :trn, 0.8321166666666666, :tst, 0.8175)\n",
      "(:epoch, 3, :trn, 0.84125, :tst, 0.8256)\n",
      "(:epoch, 4, :trn, 0.8467666666666667, :tst, 0.8295)\n",
      "(:epoch, 5, :trn, 0.8503833333333334, :tst, 0.834)\n",
      "(:epoch, 6, :trn, 0.8528666666666667, :tst, 0.836)\n",
      "(:epoch, 7, :trn, 0.8554, :tst, 0.8365)\n",
      "(:epoch, 8, :trn, 0.8572833333333333, :tst, 0.8375)\n",
      "(:epoch, 9, :trn, 0.8585166666666667, :tst, 0.8378)\n",
      "(:epoch, 10, :trn, 0.8599333333333333, :tst, 0.8391)\n",
      "  7.857764 seconds (8.35 M allocations: 4.264 GiB, 5.97% gc time)\n"
     ]
    }
   ],
   "source": [
    "model = FashionMNIST.main(\"\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 1.0.0",
   "language": "julia",
   "name": "julia-1.0"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.0.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
